
import detector

import cv2
import numpy as np





if __name__ == "__main__":
    single_img_path = "../fabric-defect/麻皮/T03825_00.bmp"
    img = detector.cv_read(single_img_path)
    detector.cv_show('img', img)
    img_EquHisto = detector.AdaptiveEquHisto(img)
    detector.cv_show('img_EquHisto', img_EquHisto)
    ret, binary = cv2.threshold(img_EquHisto, 0, 255, cv2.THRESH_BINARY | cv2.THRESH_OTSU)
    detector.cv_show('bin', binary)
    # 核的大小和形状
    kernel = cv2.getStructuringElement(cv2.MORPH_ELLIPSE, (3, 3))
    # 开操作
    ret1 = cv2.morphologyEx(binary, cv2.MORPH_OPEN, kernel, iterations=7)
    # 闭操作
    ret2 = cv2.morphologyEx(ret1, cv2.MORPH_CLOSE, kernel, iterations=5)
    detector.cv_show('ret1', ret1)
    detector.cv_show('ret2', ret2, block=True)
    # cv2.waitKey(0)

# ————————————————
# 版权声明：本文为CSDN博主「昵称格式错误」的原创文章，遵循CC 4.0 BY-SA版权协议，转载请附上原文出处链接及本声明。
# 原文链接：https://blog.csdn.net/qq_37385726/article/details/82021970